#include "../tools.h"


class Solution {
public:
    vector<vector<string>> displayTable(vector<vector<string>>& orders) {
        set<string> dishes;
        map<int, map<string, int>> tables;
        vector<vector<string>> res;

        for(auto& order: orders){
            dishes.insert(order[2]);
            tables[stoi(order[1])][order[2]] += 1;
        }
        vector<string> header = {"Table"};
        for(auto& d: dishes)
            header.emplace_back(d);
        res.emplace_back(header);

        for(auto& t: tables){
            vector<string> v = {to_string(t.first)};
            for(auto& d: dishes){
                v.emplace_back(to_string(t.second[d]));
            }
            res.emplace_back(v);
        }
        // show(res);

        return res;
    }
};


int main(int argc, char const *argv[])
{
    
    vector<vector<string>> orders = 
    {{"David","3","Ceviche"},
    {"Corina","10","Beef Burrito"},
    {"David","3","Fried Chicken"},
    {"Carla","5","Water"},
    {"Carla","5","Ceviche"},
    {"Rous","3","Ceviche"}};

    Solution s;
    vector<vector<string>> res = s.displayTable(orders);
    show(res);

    return 0;
}
